package com.stageadminserver.adminserver.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.stageadminserver.adminserver.service.ManagerService;
import com.stagecommon.common.pojo.Manager;
import com.stagecommon.common.pojo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: yxl
 * @since: 2021-12-05
 **/
@RestController
@RequestMapping("/manager")
public class ManagerController {

    @Autowired
    private ManagerService managerService;

    @PostMapping("/login")
    public RespBean login(@RequestBody Manager manager) {
        return managerService.managerLogin(manager.getManagerName(),manager.getManagerPassword());
    }
    @GetMapping("/logout")
    public RespBean logout(){
        StpUtil.logout();
        return RespBean.operationSuccess("退出成功",200,"ok");
    }

    @PostMapping("/getManagerById")
    public RespBean<Manager> getManagerById(@RequestBody Manager manager){
        return managerService.getManagerById(manager.getManagerId());
    }
}
